<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/global/global-head.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>吉车惠后台管理系统</title>
    <%@include file="/global/global-other.jsp" %>

    <script type="text/javascript">

        $(function(){
            var $sys_log_admin_login = new Object();
            var $sys_log_admin_login_Datagrid;
            var $menu;
//            var $sys_log_admin_login_toolbar = [{
//                text:'<i class="fa fa-search" aria-hidden="true"></i>刷新',
//                handler:function(){
//                    $sys_log_admin_login.reload();
//                }
//            }
//            ];
            //gird 初始化
            $sys_log_admin_login_Datagrid = $('#sys_log_admin_login_Datagrid').datagrid({
                filterBtnIconCls:'icon-filter',
//                title:'Project列表',
                remoteSort:false,
                singleSelect:true,
                nowrap:false,
                fitColumns:true,
                pagination:true,
                rownumbers:true,
                sortName:'time',
                //sortOrder:'desc',
                pagePosition:'both',
                method:'post',
                queryParams: {
                    filter_EQ_delete_status : 0,

                },
                pageSize : 20,
                remoteFilter:true,
                url:'${ctx}/sys/log/paynotify/search?_m=load',
                columns:[[
                    {field:'time',title:'时间/IP',width:'15%',sortable:true,
                        formatter: function(value,row,index){
                            return '<span>'+row.time+'</span>'+'<br>'+
                                    '<span>'+row.__source__+'</span>'+'<br>'

                                    ;
                        } },
                    /*{field:'attr1',title:'IP',width:'10%'},*/
                    {field:'message',title:'内容',width:'90%',
                        formatter: function(value,row,index){
                            return '<span style="font-weight:800;">__topic__:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.__topic__+'</a>'+'<br>'+
                                    '<span style="font-weight:800;">level:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.level+'</a>'+'<br>'+
                                    '<span style="font-weight:800;">location:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.location+'</a>'+'<br>'+
                                    '<span style="font-weight:800;">message:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.message+'</a>'+'<br>'+
                                    '<span style="font-weight:800;">thread:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.thread+'</a>'
//                                    '<span style="font-weight:800;">time:</span><a style="color:#2a6496" href="/arbcase/case-'+row.id+'">'+row.time +'</a>'

                                    ;
                        } },

                ]],
            });

//            $sys_log_admin_login_Datagrid.datagrid('enableFilter', [
//                {field:'powerName',type:'label'},
//                {field:'functionName',type:'label'},
//                {field:'ip',type:'label'},
//                {field:'visitAddress',type:'label'},
//                {field:'operationAt',type:'label'},
//                {field:'t',type:'label'}
//            ]);

            //刷新

            $sys_log_admin_login.reload = function(){
                $sys_log_admin_login_Datagrid.datagrid({
                    queryParams: {
                        title: $("#topic").textbox("getValue"),
                        keywords:$("#keywords").textbox("getValue"),
                        startDate:$("#startDate").textbox("getValue"),
                        endDate:$("#endDate").textbox("getValue")
                    }
                });
                $sys_log_admin_login_Datagrid.datagrid('reload');
            };

            $("#btnQuery").on("click",function () {
                var start = $("#startDate").textbox("getValue");
                var end = $("#endDate").textbox("getValue");
                console.log("start:" + start+ "; end:" + end);
                if( !start || !end) {
                    console.log("load empty");
                    $sys_log_admin_login_Datagrid.datagrid('loadData', { total: 0, rows: [] });
                    return;
                }
                $sys_log_admin_login_Datagrid.datagrid({
                    url:'${ctx}/sys/log/paynotify/search?_m=load',
                    queryParams: {
                        title: $("#topic").textbox("getValue"),
                        keywords:$("#keywords").textbox("getValue"),
                        startDate:start,
                        endDate:end
                    }
                });
                $sys_log_admin_login_Datagrid.datagrid('reload');
            });
            $("#btnQueryOSS").on("click",function () {
                var prefix = $("#keyPrefix").val();
                if(!prefix) {
                    $sys_log_admin_login_Datagrid.datagrid('loadData', { total: 0, rows: [] });
                    return;
                }
                $sys_log_admin_login_Datagrid.datagrid({
                    url:'${ctx}/sys/log/paynotify/searchOss',
                    queryParams: {
                        prefix:prefix
                    }});
            });
            //搜索类型radio 点击事件
            $("input.cbox").on("change",function () {
                if($(this).attr("id") == "oss"){
                    $("div#divOSS").show();
                    $("div#divReal").hide()
                }
                else if($(this).attr("id") == "real"){
                    $("div#divOSS").hide();
                    $("div#divReal").show();
                }
            });

        });

    </script>
    <style>

        #Tabfirst li {
            float: left;
            padding: 5px;
            margin-right: 2px;

        }

        div.contentfirst {
            clear: left;
            /*width: 99%;*/
            /*height:auto;*/
            /*padding: 10px 10px 0 10px;*/
            /*display: none;*/
        }
        div.contentin {
            display: block;
        }
    </style>
</head>
<body>
<!--搜索类型选择-->
<div style="clear: right">
<ul id="Tabfirst" style=" padding:5px;">
    <div style=" float:left; padding:8px 0; margin-right:5px;"><label>搜索类型：</label></div>
    <li class="tabin">
        <label class="checkbox-inline">
            <input  id="real" type="radio" class="cbox" name="stype" checked /> 实时日志
        </label>
    </li>
    <li>
        <label class="checkbox-inline">
            <input id="oss" type="radio" class="cbox" name="stype" /> 归档日志
        </label>
    </li>
</ul>
</div>
<div id="divReal" class="contentfirst contentin" style="height:auto; padding:5px; background:#FFF;">
    <%--<input id="logstore" class="col-sm-2" name="yp" value="logstore_pay" style="width:16.6666%;">--%>
    <input id="topic" class="easyui-textbox" data-options="prompt:'请输入topic'" style="width:10%;"  />

    <a id="srts" href="javascript:void(0)" style=" display:inline-block;width:20%;"><input id="keywords" class="easyui-textbox" data-options="prompt:'请输入关键字进行搜索'" style="width:100%;"/> </a>
    &nbsp;
    <input id="startDate" name="startDate" class="easyui-datetimebox" data-options="sharedCalendar:'#dataa'" style="width:20%;" />
    to
    <input id="endDate" name="endDate" class="easyui-datetimebox" data-options="sharedCalendar:'#dataa'" style="width:20%;" />
    <div id="dataa" class="easyui-calendar"></div>
    <button id="btnQuery" style="margin-right:2px" class="btn btn-primary"><i class="fa fa-search">搜索</i></button>
</div>
<!--归档日志-->
<div id="divOSS"  style="height:auto; padding:5px; background:#FFF;display: none;clear: left">
    <input id="keyPrefix" type="text" style="width:30%;height:30px;" value="pay_notify/2017/02/16/15/" placeholder="Object key 前缀,如 pay_notify/2017/02/16/15/">
     <button id="btnQueryOSS" style="margin-right:2px;" class="btn btn-primary"><i class="fa fa-search">搜索</i></button>
</div>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:false">
        <table id="sys_log_admin_login_Datagrid"  style="width:100%;height:100%">
       </table>
    </div>
</div>
</body>
</html>